import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';

import 'package:blog_chyk_intl/app/routes/routes.dart';
import 'package:blog_chyk_intl/app/theme/app_theme.dart';
import 'package:blog_chyk_intl/app/theme/theme_controller.dart';
import 'package:blog_chyk_intl/utils/index.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await GetStorage.init(); // 打开盒子
  Get.put(ThemeController()); // ← 提前放好，全局都能 find 主题
  runApp(const BlogChykIntl());
}

class BlogChykIntl extends StatelessWidget {
  const BlogChykIntl({super.key});

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      debugShowCheckedModeBanner: false,
      initialRoute: RoutesName.home,
      getPages: AppPages.routes,
      translations: Messages(), // ← 翻译源
      locale: getInitialLocale(), // ← 初始语言（工具函数）
      fallbackLocale: const Locale('en'),
      theme: AppTheme.light,
      darkTheme: AppTheme.dark,
      themeMode: ThemeMode.system,
    );
  }
}
